package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class NewForDemo {
    public static void main(String[] args) {
        String[] array ={"one","two","three","four","five"};
        for (int i = 0; i < array.length ; i++) {
            System.out.println(array[i]);
        }

        for (String str:array){//Str是元素名，可以自由更改，新循环，底层逻辑依然是迭代器，不能通过集合增删
            System.out.println(str);//遍历循环更方便
        }

        Collection c =new ArrayList();
        c.add("one1");
        c.add("two1");
        c.add("three1");
        c.add("four1");
        c.add("five1");


        Iterator it =c.iterator();
        while(it.hasNext()){
            String str =(String)it.next();
            System.out.println(str);
        }


    }
}
